using System;
using Castle.ActiveRecord;
using DecisionMaking.Domain.Reports;

namespace DecisionMaking.Domain
{
	[ActiveRecord]
    [Import(typeof(CompetitionResultReportEntry), "CompetitionResultReportEntry")]
    [Import(typeof(AlgorithmPerformanceReportEntry), "AlgorithmPerformanceReportEntry")]
    public class AlgorithmExecutionOutcome : ActiveRecordValidationBase<AlgorithmExecutionOutcome>
    {
        [PrimaryKey(PrimaryKeyType.Native)]
        public int Id { set; get; }

        [BelongsTo(NotNull = true)]
        public SimulationOutcome Simulation { get; set; }

        [BelongsTo(NotNull = true)]
        public AlgorithmDefinition AlgorithmDefinition { get; set; }

        [BelongsTo(NotNull = true)]
        public Agent Agent { get; set; }

        [Property]
        public double AvgRuntimeInMillis { get; set; }

        [Property]
        public double AvgCuesUsed { get; set; }

        [Property]
        public int NumOfCandidatesRecognized { get; set; }

        [Property]
        public int TotalComparisons { get; set; }

        [Property]
        public int NumOfCorrectInferences { get; set; }

        [Property]
        public double AvgAccuracy { get; set; }

	    public bool Equals(AlgorithmExecutionOutcome other)
	    {
	        if (ReferenceEquals(null, other)) return false;
	        if (ReferenceEquals(this, other)) return true;
	        return other.Id == Id;
	    }

	    public override bool Equals(object obj)
	    {
	        if (ReferenceEquals(null, obj)) return false;
	        if (ReferenceEquals(this, obj)) return true;
	        if (obj.GetType() != typeof (AlgorithmExecutionOutcome)) return false;
	        return Equals((AlgorithmExecutionOutcome) obj);
	    }

	    public override int GetHashCode()
	    {
	        return Id;
	    }
    }
}